home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekkan Dennou Club 143
/
Gekkan Dennou Club - 2000.4 Vol. 143 (Japan).7z
/
Gekkan Dennou Club - 2000.4 Vol. 143 (Japan).bin
/
docs
/
perl
/
tajyu.pl
< prev
Wrap
Perl Script
|
2000-02-26
|
763b
|
60 lines
#
# 多重継承のテスト
#
package Foo;
sub new {
my ($type, $a) = @_;
my $obj = {'a' => $a };
bless $obj, $type;
$obj;
}
sub get_a {
my $obj = shift;
$obj->{'a'};
}
sub method_1 {
print "Foo::method_1\n";
}
package Bar;
sub new {
my ($type, $b) = @_;
my $obj = {'b' => $b };
bless $obj, $type;
$obj;
}
sub get_b {
my $obj = shift;
$obj->{'b'};
}
sub method_1 {
print "Bar::method_1\n";
}
package Baz;
@ISA = (Foo, Bar);
sub new {
my ($type, $a, $b) = @_;
my $obj = {'a' => $a, 'b' => $b };
bless $obj, $type;
$obj;
}
package main;
# $o1 = Baz->new(10,20);
# 間接記法
$o1 = new Baz 10, 20;
print $o1->get_a(), "\n";
print $o1->get_b(), "\n";
$o1->method_1();